package main

import "fmt"

type PayStrategy01 interface {
	Pay() // 支付
}

var payModeMap = map[string]PayStrategy01{
	"ali":    AliPay01{},
	"wechat": WechatPay01{},
}

type AliPay01 struct {
}

func (a AliPay01) Pay() {
	fmt.Println("支付宝支付...")
}

type WechatPay01 struct {
}

func (w WechatPay01) Pay() {
	fmt.Println("微信支付...")
}

func main() {
	payStrategy, has := payModeMap["ali"]
	if has {
		payStrategy.Pay()
	}

	payStrategy, has = payModeMap["wechat"]
	if has {
		payStrategy.Pay()
	}
}
